package com.itheima.mapper;

import com.itheima.pojo.Goods;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface GoodsMapper {

    /**
     * 查询所有
     * @return
     */
    @Select("select * from goods")
    //@ResultMap("brandResultMap")
    List<Goods> selectAll();

    /**
     * 添加数据
     * @param goods
     */
    @Insert("insert into goods values(null,#{name},#{price},#{num},#{introduce})")
    void add(Goods goods);


    /**
     * 批量删除
     * @param ids
     */
    void deleteByIds(@Param("ids") int[] ids);

    @Delete("delete  from goods where goods_id=#{id}")
    void deleteById(@Param("id") int id);

    /**
     * 分页查询
     * @param begin
     * @param size
     * @return
     */
    @Select("select * from sinformation limit #{begin} , #{size}")
    //@ResultMap("brandResultMap")
    List<Goods> selectByPage(@Param("begin") int begin, @Param("size") int size);

    /**
     * 查询总记录数
     * @return
     */
    @Select("select count(*) from goods ")
    int selectTotalCount();



    /**
     * 分页条件查询
     * @param begin
     * @param size
     * @param goods
     * @return
     */
    List<Goods> selectByPageAndCondition(@Param("begin") int begin, @Param("size") int size, @Param("goods") Goods goods);

    /**
     * 根据条件查询总记录数
     * @return
     */
    int selectTotalCountByCondition(Goods goods);
    @Update("update goods set goods_name=#{name},goods_price=#{price},goods_num=#{num},goods_introduce=#{introduce} where goods_id=#{id}")
    void updateById(Goods goods);
}
